﻿using System.Xml.Linq;
using Schema = QASPRibbon.RibbonSchema;

namespace QASPRibbon.Controls
{
    /// <summary>
    /// Label for another control
    /// </summary>
    public class RibbonLabel : RibbonVisualControl
    {
        internal override XElement AsXElement()
        {
            var element = base.AsXElement();
            element.Add(new XAttribute(Schema.ForId, NameSpace + "." + ForId));
            element.Add(new XAttribute(Schema.LabelText, Title));
            if (!string.IsNullOrEmpty(TemplateAlias))
                element.Add(new XAttribute(Schema.TemplateAlias, TemplateAlias));
            return element;
        }

        internal override string XmlTag
        {
            get { return Schema.Label; }
        }

        /// <summary>
        /// The ID of the control that this control labels.
        /// </summary>
        public string ForId;

        /// <summary>
        /// Creates and initializes a new instance of the RibbonLabel.
        /// </summary>
        public RibbonLabel() { }

        /// <summary>
        /// Creates and initializes a new instance of the RibbonLabel.
        /// </summary>
        /// <param name="id">Identifier</param>
        public RibbonLabel(string id) : base(id) { }

        /// <summary>
        /// Creates and initializes a new instance of the RibbonLabel.
        /// </summary>
        /// <param name="id">Identifier</param>
        /// <param name="title">Label text</param>
        public RibbonLabel(string id, string title) : base(id, title) { }
    }
}
